#pragma once

#ifndef LHJ_CORE_COMMON_RESOURCE_H__
#define LHJ_CORE_COMMON_RESOURCE_H__

#include <cstdint>
#include <model.h>
#include <string>

namespace cores
{
    namespace common
    {
        using namespace std;
        using namespace cores::datas::models::terminal;
        /**
         * @brief 资源类
         */
        class Resources
        {
        public:
            static uint16_t crc16(const uint8_t *data, const int &size);

            template <typename T>
            int valueToHexChar(const T& value, uint8_t * buffer, const int &size)
            {
                auto s = sizeof(T);
                uint8_t * data = (uint8_t*)(&value);
                for (auto i = 0; i < s; i++)
                    buffer[i] = data[i];
                return s;
            }

            /**
             * @brief Lora令牌环协议
             */
            virtual int transData2TokenChar(uint8_t * buffer, const int& size, const OilTransReq& model, const uint32_t& now_time);

            /**
             * @brief 将字节流转换成16进制字符串
             */
            static string bytesToHexStr(const uint8_t* buffer, const int& size);
        };
    }
}

#endif